

const MongoClient = require('mongodb').MongoClient;
const url = 'mongodb://127.0.0.1:27017';
const db_name = 'yzzy';

console.log('ok');

(async () => {
    const client = new MongoClient(url);
    try {
        await client.connect();
        const database = client.db(db_name);
        const col_products = database.collection('products');
        const product_list = col_products.find();
        // console.log(product_list);
        while (await product_list.hasNext()) {
            const p = await product_list.next();
            console.log(p.name);
        }
    } catch (e) {
        console.log(e.stack);
    }
    await client.close();
})();